﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace Mall.Member
{
    public partial class Member_Pwd : System.Web.UI.Page
    {
        public string Change_result = string.Empty;
        public MODEL.MMember model = new MODEL.MMember();
        protected void Page_Load(object sender, EventArgs e)
        {


            BLL.Models.MemberModels models_member = new BLL.Models.MemberModels();
            string _username = models_member.CheckUserId();
            DataTable dt = new DataTable();
            dt = models_member.GetuserInfoByFiter("  Username='" + _username + "' ");
            model.UserName = dt.Rows[0]["username"].ToString();
            model.Id = Convert.ToInt32(dt.Rows[0]["id"].ToString());
            model.UserPwdQuestion = Convert.IsDBNull(dt.Rows[0]["UserPwdQuestion"]) == true ? "" : dt.Rows[0]["UserPwdQuestion"].ToString();
            model.UserPwdPwd = Convert.IsDBNull(dt.Rows[0]["UserPwdPwd"]) == true ? "" : dt.Rows[0]["UserPwdPwd"].ToString();
            //ViewData["Member_pwd_ModelMember"] = model;
            string _UserQuestion2 = Request["UserQuestion2"] == null ? "" : Request["UserQuestion2"].ToString();
            string _UserAnswer22 = Request["UserAnswer22"] == null ? "" : Request["UserAnswer22"].ToString();
            string _UserQuestion12 = Request["UserQuestion12"] == null ? "" : Request["UserQuestion12"].ToString();
            string _UserAnswer12 = Request["UserAnswer12"] == null ? "" : Request["UserAnswer12"].ToString();
            if (_UserAnswer12 != "")
            {

                if (_UserQuestion2 == model.UserPwdQuestion && _UserAnswer22 == model.UserPwdPwd)
                {

                    model.UserPwdQuestion = _UserQuestion12;
                    model.UserPwdPwd = _UserAnswer12;
                    models_member.ChangePwdAnswer(model);
                    Change_result = "yes";

                }
                else
                {

                    Change_result = "no";
                }
            }

        }
    }
}